package com.test.rest.server;

import java.util.HashMap;
import java.util.Map;

import javax.ws.rs.GET;
import javax.ws.rs.Path;
import javax.ws.rs.PathParam;
import javax.xml.bind.annotation.XmlRootElement;

@XmlRootElement(name = "Order")
public class Order {

	private long id;

	private String description;

	private Map<Long, Product> products = new HashMap<Long, Product>();

	public Order() {

		Product product = new Product();

		product.setId(323);
		product.setDescription("product 323");

		products.put(product.getId(), product);

	}

	public long getId() {
		return id;
	}

	public void setId(long id) {
		this.id = id;
	}

	public String getDescription() {
		return description;
	}

	public void setDescription(String description) {
		this.description = description;
	}

	@GET
	@Path("/products/{productId}")
	public Product getProduct(@PathParam("productId") int productId) {
		
		System.out.println("productId : " + productId);
		
		Product product = this.products.get(new Long(productId));
		
		return product;
		
	}
	
}
